package com.zuoye.zuoye3;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        list.add(new Student("王三", 20));
        list.add(new Student("张三", 18));
        list.add(new Student("李三", 17));
        list.add(new Student("刘三", 18));
        list.add(new Student("张三", 16));
        list.add(new Student("张三", 18));
        list.add(new Student("张五", 21));
        list.add(new Student("张四", 20));
        list.add(new Student("张二", 22));
        list.add(new Student("张一", 19));
        list.forEach(System.out::println);

        System.out.println("===================");
        HashSet<Student> set = new HashSet<>();
        Iterator<Student> iterator = list.iterator();
        while (iterator.hasNext()) {
            Student s =  iterator.next();
                set.add(s);

        }
        set.forEach(System.out::println);


    }
}
